package com.igoal.exception;

public class LoginException extends Exception {

	private static final long serialVersionUID = -6581753165590812634L;

	public static int USER_NOT_EXIST = 1;
	public static int WRONG_PASSWORD = 2;
	public static int ACCOUNT_LOCKED = 3;
	public static int ACCOUNT_DISABLE = 4;
	public static int NO_PASSWORD_ENCODER = 5;

	private int errorCode;

	public LoginException(int errorCode) {
		this.errorCode = errorCode;
	}

	public int getErrorCode() {
		return errorCode;
	}

	@Override
	public String getMessage() {
		if (errorCode == USER_NOT_EXIST) {
			return "Username does not exist";
		} else if (errorCode == WRONG_PASSWORD) {
			return "Wrong password";
		} else if (errorCode == ACCOUNT_DISABLE) {
			return "Account is disable";
		} else if (errorCode == ACCOUNT_LOCKED) {
			return "Account is locked";
		} else {
			return "Internal error";
		}
	}

}
